<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var arr = [10, 15, 2, 32, 5, 4, 20, 8, 48, 54, 6]
        var sum = []
        // 遍历数组
        for (var i = 0; i < arr.length; i++) {
            // 判断数据中每个元素是否小于10
            if (arr[i] < 10) {
                // 将小于10的元素添加到sum新数组中
                sum.push(arr[i])
            }
        }
        console.log(sum)

        // 定义res变量，将sum数组中的元素按照从小到大的顺序排列并赋值给变量res
        var res = sum.sort(function (a, b) {
            return a - b
        });
        console.log(res)
    </script>
</body>

</html>